<template>
	<div class="container">
		<!-- <navigationBar :title="'007'"></navigationBar> -->
		<div v-if="true">
			<div class="nav" :style="'padding-top: ' + statusBarHeight + 'px;'">
				<div class="warp">
					<div class="left">
						<div class="back" @click="$navSkin.goBack">
							<image class="back_img" src="/static/icon/arrows.png" alt="">
						</div>
						<image class="user-icon" :src="chatUser.avatar" mode="aspectFill"></image>
						<div class="user-name">{{chatUser.nickname}}</div>
					</div>
					<div class="right" :style="platform == 'WEIXIN'?'padding-right:'+ (wxMenuButtonWidth+10)+'px':''">
						<div class="follow-active" v-if="!chatUser.follow" @click="follow(chatUser.id)">
							关注
						</div>
						<div class="follow" v-else @click="unfollow(chatUser.id)">
							已关注
						</div>
					</div>
				</div>
			</div>
			<div class="content" :style="'padding-top: ' + (navigationBarHeight-1) + 'px;'">
				<div class="buy" v-if="lastInformation">
					<div class="buy-left">
						<image class="buy-pic"
							:src="$utils.imgfileSuffix(lastInformation.firstFileSuffix) ?lastInformation.firstPicturePath:lastInformation.firstCoverPath"
							mode="aspectFill"></image>
						<div class="pri-box">
							<div class="pri-title">{{lastInformation.title}}</div>
							<div class="pri-wrap">
								<span class="price" v-if="lastInformation.price"><span
										class="price-icon">￥</span>{{lastInformation.price}}</span>
								<span v-if="lastInformation.freeShipping" class="attr">包邮</span>
							</div>
						</div>

					</div>
					<div class="buy-want" @click="toSendInfo(lastInformation)">发送</div>
					<image @click="clearLastInformation" class="close" src="../../static/icon/close2.png" mode="">
					</image>
				</div>
				<div class="scroll" @click="hideOtherSend" :style="'height: ' + scrollHeight + 'px;'">
					<scroll-view class="scroll-view" :scroll-y="true" :scroll-into-view="scrollIntoView"
						style="height: 100%;" :scroll-with-animation="true" :scroll-top="scrollTop">

						<chatText v-for="(item, key) in messageList" :key="key" :isMe="(u_id == item.toUserId)"
							:avatar="item.sendUserAvatar"
							:messageType="item.type == 1? 'text':item.type == 2? 'image':item.type == 3? 'information':'money'"
							:message="item" @hanlderMoney="hanlderMoney">
						</chatText>

					</scroll-view>
				</div>
				<div class="input-warp" ref="myInput" id="input_warp">
					<chatInput ref="chatInputRef" :commonLanguage="commonLanguage" :value="chartMessgae" @blur="
							e => {
								// chartMessgae = e;
								scrollIntoView = '';
							}
						" @focus="
							() => {
								scrollIntoView = 'mark_' + lastMark;
							}
						" @input="
							e => {
								chartMessgae = e;
							}
						" @linechange="
							e => {
								chatInputHeight = e;
								scrollIntoView = 'mark_' + lastMark;
							}
						" @send="submitForm" @upload="handlerUpload" @getShop="hanlderShop" @sendMoney="sendMoney"></chatInput>
				</div>
			</div>
		</div>

		<myBaby v-if="false"></myBaby>
	</div>
</template>

<script>
	import data from '@/js/index/advisory/data.js';
	import methods from '@/js/index/advisory/methods.js';
	import {
		mapState
	} from 'vuex';
	import navigationBar from '../../components/navigationBar.vue';
	import chatText from '@/components/chatText.vue';
	import chatInput from '@/components/chatInput.vue';
	import uniPopup from "@/components/uni-popup/uni-popup.vue";
	import myBaby from "@/pages/index/myBaby.vue";
	export default {
		data,
		methods,
		onLoad(e) {
			this.getUserInfo()
			this.u_id = e.user_id || 0
			this.getPageData()
			// this.changeTime()
			this.getChatUserInfo()
			// this.getUnlockDescription()
			// this.getUnlockSetting()


		},
		onShow() {
			this.chatInputHeight = uni.upx2px(98);
			// 连接
			this.connect()
			this.connectlisenter()
		},
		onHide() {
			clearInterval(this.timeRequest)
			this.unsubscribe()
		},
		onUnload() {
			this.unsubscribe()
			clearInterval(this.timeRequest)
		},
		components: {
			navigationBar,
			chatText,
			chatInput,
			uniPopup,
			myBaby
		},
		computed: {
			...mapState(['navigationBarHeight', 'statusBarHeight', 'userInfo', 'platform', 'safeAreaInsetsBottom',
				'lastInformation', 'wxMenuButtonWidth'
			]),
			scrollHeight() {
				return uni.getSystemInfoSync().windowHeight - this.navigationBarHeight - this.chatInputHeight - uni.upx2px(
					20) - this.safeAreaInsetsBottom;
			}
		}
	};
</script>
<style>
	/*每个页面公共css */
	/* 解决小程序和app滚动条的问题 */
	/* #ifdef MP-WEIXIN || APP-PLUS */
	::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
		color: transparent;
	}

	/* #endif */

	/* 解决H5 的问题 */
	/* #ifdef H5 */
	uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
		/* 隐藏滚动条，但依旧具备可以滚动的功能 */
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
		color: transparent;
	}

	/* #endif */
</style>
<style scoped lang="scss">
	@import '~@/style/index/advisory.scss';
</style>